import {getDetailDataRequest} from '@/api'

const state = {
    detailData:{}
}

const mutations={
    SET_DETAILDATA_STATE(state,value){
        state.detailData = value
    }
}

const actions = {
   async getDetailData({commit},skuId){
        const re = await getDetailDataRequest(skuId)
        commit('SET_DETAILDATA_STATE',re)
    }
}

const getters = {
    //拿到里面的三组数据
    categoryView(state){
        return state.detailData.categoryView || {}
    },
    spuSaleAttrList(state){
        return state.detailData.spuSaleAttrList || []
    },
    skuInfo(state){
        return state.detailData.skuInfo || {}
    },
}

export default{
    namespaced:true,
    state,
    mutations,
    actions,
    getters
}